/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			pgatomicchg.h
  \date			Jun 2012
  \author		TNick

  \brief		Contains the definition for AtomicChg class


*//*


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read COPYING and README files in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __PGATOMICCHG_INC__
#define __PGATOMICCHG_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<cpg/cpg.h>
#include	<cpg/cpg_global.h>
#include	<atomicchg.h>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

namespace	cpg		{

class	CpgDoc;
class	PgSpace;

/**
*	@brief	Base class for all atomic changes to a document
*
*	These changes may be done and undone. The implementation offers the
*	possibility to use same class for two opposite actions. For example, a class for
*	creating a new element in the document may be reused for deleting same kind
*	of element from the document by using the same class with the FL_REVERSED
*	flag set.
*
*	For an comprehensive discussion about Undo/Redo functionality see
*	\ref undo "dedicated page".
*/
class CPGSHARED_EXPORT AtomicChg		: public BBlocks::AtomicChg	{
	BBM_TRACK( AtomicChg );

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

protected:

	/**
	*	@brief	associated document; must be non-null
	*/
	CpgDoc *				assoc_doc_;


	/**
	*	@brief	associated space; may be null
	*/
	PgSpace *			assoc_space_;


	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:


	/**
	*	@brief	constructor;
	*/
	AtomicChg			( CpgDoc * doc, PgSpace * s = NULL );


	/**
	*	@brief	destructor;
	*/
	virtual				~AtomicChg			( void );


	/**
	*	@brief	tell associated document
	*/
	inline CpgDoc *		document			( void )
	{ return assoc_doc_; }


	/**
	*	@brief	tell associated view (is ok to be NULL)
	*/
	inline PgSpace *	space				( void )
	{ return assoc_space_; }


	/**
	*	@brief	change associated view (is ok to be NULL)
	*/
	inline void			setSpace			( PgSpace * s )
	{ assoc_space_ = s; }


	/**
	*	@brief	insert this change on top of the undo stack
	*/
	void				pushMe				( void );



private:


	/**
	*	@brief	recreate the effect of this change
	*/
	void				redo				( void );


	/**
	*	@brief	undo the effect of this change
	*/
	void				undo				( void );


	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class AtomicChg	*/

/*  CLASS    =============================================================== */
//
//
//
//

}	//	namespace	cpg

#endif // __PGATOMICCHG_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
